#pragma once
#include "MysqlDao.hpp"
#include "Singleton.hpp"
#include "data.hpp"
#include <json/json.h>
#include <memory>
#include <string>
#include <vector>
class MysqlMgr : public Singleton<MysqlMgr> {
  friend class Singleton<MysqlMgr>;

private:
  MysqlMgr();
  MysqlDao _dao;

public:
  int RegUser(const std::string &name, const std::string &email,
              const std::string &pwd);
  bool CheckEmail(const std::string &email);
  bool UpdatePwd(const std::string &email, const std::string &pwd);
  bool CheckPwd(const std::string &email, const std::string &pwd,
                UserInfo &userInfo);
  bool AddFriendApply(const FriendApplyInfo &);
  std::shared_ptr<UserInfo> GetUser(int uid);
  std::shared_ptr<UserInfo> GetUser(std::string name);
  bool GetApplyInfo(int, std::vector<std::shared_ptr<FriendApplyInfo>> &, int,
                    int);
  bool MakeFriend(int fromuid, int touid, std::string remark);
  bool GetFriends(int, std::vector<std::shared_ptr<FriendInfo>> &);
  bool SaveMessage(std::shared_ptr<TextMessage>);

  void SureMessage(int touid, const std::vector<std::string> &msg_id_list);
  void LoadMessage(int touid,
                   std::vector<std::shared_ptr<TextMessage>> &messageList);
  ~MysqlMgr();
};